<?php
class Db_Mysql{
	
	public function findAll($table,$where='',$return='*',$order='',$group='',$limit=''){
		if(!empty($where)){
			$where = ' where '.$where;
		}
		if(!empty($order)){
			$order = ' order by '.$order;
		}
		if(!empty($group)){
			$group = ' group by '.$group;
		}
		if(!empty($limit)){
			$limit = ' limit '.$limit;
		}
		$sql = 'select '.$return.' from '.$table.$where.$order.$group.$limit;
		$ret = mysql_query($sql);
		while ($row = mysql_fetch_array($ret)){
			$out[] = $row;
		}	
		
		return $out;
	}
	
	public function find($table,$where='',$return='*',$order='',$group=''){
		if(!empty($where)){
			$where = ' where '.$where;
		}
		if(!empty($order)){
			$where = ' order by '.$order;
		}
		if(!empty($group)){
			$where = ' group by '.$group;
		}
		
		$sql = 'select '.$return.' from '.$table.$where.$order.$group.' limit 1';
		$ret = mysql_query($sql);
		$row = mysql_fetch_array($ret);
		return $row;
	}
}